#ifndef ANIMATION_H_
#define ANIMATION_H_

// INCLUDES //
#include "object.h"
#include <vector.h>
//////////////

// DEFINES //
#define ANIM_DELAY				100

/**
* An object that represents a general animation object.
* 
* @author dfoelber
**/
class AnimationObject : public Object
{
public:
	enum Duration
	{
		DURATION_EXTERNAL = 0, // externally defined duration
		DURATION_PATH,
		DURATION_ONCE
	};
public:
	/**
	* Constructor
	**/
	AnimationObject(int id = OBJECT_ID_ANIMATION);
	
	/**
	* Deconstructor
	**/
	virtual ~AnimationObject();
	
	/**
	* Accessor to the object's image.
	* 
	* Overridden from Object
	* 
	* @return the surface
	**/
	virtual Surface* GetSurface() { return image; }

	/**
	* Lets the object know that time has passed and to move accordingly.
	* 
	* @param ms The time passed since last called
	* 
	* overridden from Object
	**/
	virtual void TimePassed( int ms );
	
	/**
	* Sets the animation vector.
	* 
	* @param anim The animation surfaces
	* @param reversed If the animation starts reversed
	* @param rotate If the animation should rotate
	**/
	void SetAnimationImages( vector<Surface*> anim, bool reversed, bool rotate, Duration duration, bool owner = false );
	
	/**
	* Returns the mode of the animation.
	* 
	* @return The mode
	**/
	Duration GetAnimationDuration() { return duration; }
	
	/**
	* Returns if the object is animating.
	* 
	* Overridden from Object
	* 
	* @return If the object is animating
	**/
	virtual bool IsAnimating() { return animate; }
	
	/**
	* Forces the object to stop animating.
	**/
	void StopAnimating() { animate = false; }
	
	/**
	* Sets the animation delay.
	* 
	* @param delay The new delay
	**/
	void SetAnimationDelay(int delay) { animationDelay = delay; }
	
private:
	/// The image of the object
	Surface*				image;
	/// The animation surfaces
	vector<Surface*>		anims;
	/// The color key for the image
	int						colorKey;
	/// The color key for the zotozoom
	int						rotoKey;
	/// Animation counter
	int						animCounter;
	/// Animation index
	int						animIndex;
	/// If the object should rotate
	bool					rotate;
	/// The duration of the animation
	Duration				duration;
	/// If the object is animating
	bool					animate;
	/// If the object owns the animation images
	bool					animationOwner;
	/// The animation delay
	int						animationDelay;
};

#endif /*ANIMATION_H_*/
